package letcode;


import 算法.排序.paixu;

import java.util.ArrayList;
import java.util.Scanner;
import java.util.function.Consumer;

public class exam {
    public static void main(String[] args) {
        int arr[]={4,5,2,7,3,9,1};
        quicksort(arr,0,arr.length-1);
        tools.arrayout(arr);
    }

    private static void aout(int[] arr) {
        for (int i=0;i<arr.length;i++)
        {
            System.out.print(arr[i]+" ");
        }

    }
    private static void quicksort(int[] arr, int low, int high) {
        if (low>high) return;
        int index=getdex(arr,low,high);
        quicksort(arr,low,index-1);
        quicksort(arr,index+1,high);
    }

    private static int getdex(int[]arr,int low,int high)
    {
        int temp=arr[low];
        for ( int i=0;i<arr.length;i++)
        {
            while (low<high && arr[high]>temp)
            {
                high--;
            }
            arr[low]=arr[high];
            while (low<high && arr[low]<temp)
            {
                low++;
            }
            arr[high]=arr[low];
        }
         arr[low]=temp;
        return low;
    }
}



